﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDie : MonoBehaviour
{
    public GameObject gameOver;

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.name == "player")
        {
            if (!gameOver.activeSelf)
            {
                gameOver.SetActive(true);
                AudioManager._instance.SetAudio(AudioClipType.DIE);
            }

            MapMove move1 = GameObject.Find("map1").GetComponent<MapMove>();
            move1.enabled = false;
            MapMove move2 = GameObject.Find("map2").GetComponent<MapMove>();
            move2.enabled = false;

            Rigidbody2D playerRigidbody2D = GameObject.Find("player").GetComponent<Rigidbody2D>();
            Destroy(playerRigidbody2D);

            GameServer.getSingleton().SetMaxScore();
        }
    }

}
